/*
* AbstractAccount
*
* r2
*
* GNU General Public License v3.0
*/

package com.acme.bankapp.domain.account;

import com.acme.bankapp.exceptions.*;

public abstract class AbstractAccount implements Account {

	// use that for hashing
	// BTW we can use Object's hashing function
	// as it use unique object's memory address
	protected static int ids = 0;
	
	private int id;
	
	protected AbstractAccount() {
		this.id = AbstractAccount.ids++;
	}
	
	public abstract void deposit(final double amount);
	
	public abstract void withdraw(final double amount) throws NotEnoughFundsException;
	
	public abstract double maximumAmountToWithdraw();
	
	public abstract double getBalance();
	
	public abstract long decimalValue();
	
	public int hashCode() {
		int hash = 56;
		
		hash = hash * 3 + id * 45;
		
		return hash;
	}
	
	public boolean equals(Object obj) {
		return obj == this;
	}

}
